package member

import (
	"github.com/astaxie/beego/orm"
	"time"
)

//用户表
type Group struct {
	Id int `orm:"pk;auto"`
	MgroupName string `orm:"unique;size(30);description(会员组名)"`
	MgroupOpen int `orm:"default(0);description(会员组是否开放,1开发 0不开放)"`
	MgroupToplimit int `orm:"default(0);description(积分上限)"`
	MgroupBomlimit int `orm:"default(0);description(积分下限)"`
	MgroupOrder int `orm:"default(0);description(排序)"`
	IsDelete int `orm:"default(0);description(1删除，0未删除)"`
	Member []*Member `orm:"reverse(many)"`
}

type Member struct {
	Id int `orm:"pk;auto"`
	UserName string `orm:"unique;column(username);size(30);description(登录用户名)"`
	Pwd string `orm:"size(60);description(登录密码)"`
	Salt string `orm:"size(10);description(密码盐值)"`
	NickName string `orm:"column(nickname);size(60);description(昵称)"`
	City string `orm:"size(60);description(市)"`
	Town string `orm:"size(60);description(区县)"`
	Sex int `orm:"default(3);description(1=男  2=女 3=保密)"`
	Headpic string `orm:"size(150);description(会员头像路径)"`
	Tel string `orm:"size(20);description(手机)"`
	Email string `orm:"size(60);description(邮箱)"`
	Open int `orm:"default(0);description(状态)"`
	CreateTime time.Time `orm:"auto_now;type(datetime);description(创建时间);null"`
	UserUrl string `orm:"size(100);description(个人网站)"`
	Birthday time.Time `orm:"auto_now;type(date);description(生日);null"`
	Signature string `orm:"size(255);description(签名)"`
	LastLoginIp string `orm:"size(60);description(ip)"`
	LastLoginTime time.Time `orm:"auto_now;type(datetime);description(最后登录时间);null"`
	Score int `orm:"default(0);description(积分)"`
	Coin int `orm:"default(0);description(金币)"`
	IsDelete int `orm:"default(0);description(1删除，0未删除)"`
	Group *Group `orm:"rel(fk)"`
}


//会员分组
func (r *Group) TableName() string {
	return "sys_member_group"
}

func (r *Member) TableName() string {
	return "sys_member_list"
}

func init()  {
	orm.RegisterModel(
		new(Group),
		new(Member),
	)
}